package com.qust;

import com.qust.enDecrpytion.annotations.Decryption;
import com.qust.enDecrpytion.annotations.EnDecryptionConfiguration;
import com.qust.enDecrpytion.annotations.EnableEnDecryption;
import com.qust.enDecrpytion.annotations.Encryption;
import com.qust.enDecrpytion.encryptionAndDecryption.local.SM2;
import com.qust.enDecrpytion.proxy.builder.EnDecryptionProxyBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@EnDecryptionConfiguration(
//        remote = @EnDecryptionConfiguration.Remote(
//                algorithmCode = 17
//        ),
        local = @EnDecryptionConfiguration.Local(
                enDecryption = SM2.class,
                keyPath = "EnDecryption-api/src/test/java/com/qust/fan.properties",
                password = "fan"
        )
)
public class Hello {
    private int id;

    public Hello(int id) {
        this.id = id;
    }

    public Hello() {

    }

    public static void main(String[] args) throws IllegalAccessException, NoSuchMethodException, InterruptedException {
        Hello hello = EnDecryptionProxyBuilder.proxy(new Hello(1));
        System.out.println("hello返回值:\n" +
                hello.hello(
                        "asd",
                        new Demo("asd", "dasd")));
        System.out.println(hello);


    }

    @EnableEnDecryption
    public @Encryption String hello(@Encryption String name, @Encryption Demo demo) {
        System.out.println("name:\n" + name);
        System.out.println("demo.id:\n" + demo.getId());
        System.out.println("demo.name:\n" + demo.getName());
        return "1";
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    static class Demo {
        @Encryption
        private String name;
        @Decryption
        private String id;
    }
}
